package com.cskaoyan.service.wx.cqw;

import com.cskaoyan.mapper.MarketFeedbackMapper;
import com.cskaoyan.module.bean.BaseRespVo;
import com.cskaoyan.module.bo.wx.cqw.FeedBackBo;
import com.cskaoyan.module.pojo.MarketFeedback;
import com.cskaoyan.module.pojo.MarketFeedbackExample;
import com.cskaoyan.module.pojo.MarketUser;
import javafx.scene.input.DataFormat;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class FeedBackServiceImpl implements FeedBackService {
@Autowired
    MarketFeedbackMapper marketFeedbackMapper;

    @Override
    public BaseRespVo injectFeedBack(FeedBackBo feedBackBo) {
        Subject subject = SecurityUtils.getSubject();
        MarketUser primaryPrincipal = (MarketUser) subject.getPrincipals().getPrimaryPrincipal();

        Date date = new Date(System.currentTimeMillis());
        MarketFeedback marketFeedback = new MarketFeedback();
        marketFeedback.setAddTime(date);
        marketFeedback.setContent(feedBackBo.getContent());
        marketFeedback.setFeedType(feedBackBo.getFeedType());
        marketFeedback.setDeleted(false);
        marketFeedback.setHasPicture(feedBackBo.getHasPicture());
        marketFeedback.setPicUrls(feedBackBo.getPicUrls());
        marketFeedback.setUserId(primaryPrincipal.getId());
        marketFeedback.setUsername(primaryPrincipal.getUsername());
        marketFeedback.setMobile(feedBackBo.getMobile());
        Byte status = primaryPrincipal.getStatus();
        marketFeedback.setStatus((int)status);
        int i = marketFeedbackMapper.insertSelective(marketFeedback);
        if (i>0){
            return BaseRespVo.ok(null);
        }
        return BaseRespVo.invalidData();
    }
}
